Refactoring Javascript.