refactored the entire app