Trying to tidy main function --