tidying up and moving my functions around