refactored framework logic