Refactored frontend js