Refactored code throughout the app