started refactoring in order to provide a more flexible framework