Almost done Tidying up code