refactor main to be easier to read