Remove duplication on javascripts