little refactoring js :)