Refactored code and added SPA