tidying up code