Small refactoring of client javascript