client app js refactoring