Refactor na javascript