refactor sales js