Refactored frontend code