Refactored the front-end code