refactor js service