Refactoring da' js.