Created service classes and refactored scripts