refactoring frontend js