tidy up some code