refactor js finished