In hindsight I should not have deleted that code that worked perfectly well and replaced it with code that didn't work.Also in hindsight I should have been using a code repository to back up my work.