added service layer + some refactoring