Refactored front end code