Cleaned up some code in main to avoid extra function calls.