clean code
javascript refactoring