refactor code. use path instead of id when calling service