Tidying up code