1 refactor js code