tidy up of the code