Refactored functionality into Service