Complete refactor of list javascript