refactoring frontend code