add service client. refactor code