tidying up some code