tidy up of code