Things seem to work perfectly now. Just need to tidy up everythng up