comments removed and functions tidied up