Small js code refactoring.