take main function out of contructor function and put it back where it was before. Tidy up formatting & indentation