Refactoring  fastedit javascript