refactor
small refactoring of js