Had a bit of a play and refactor with this and got it to a decent standard