Refactored code in Application class