Basically turned main into one method.