tidied up code for consistency