Refactored to shorten main