refactored code and introduced interfaces