refactor js codes in mod