Refactored the service functions.