refactor service js