tidy up all the code