refactored the app