tidy up the code