more tidying up code