tidying up code a bit