Tidy up
Debugged and working