tidy up code & comments