major refactoring towards seperation of concerns