JS Minor refactoring