refactored frontend code