refactored services and connection into separate classes