refactoring web service code