refactor framework, incomplete yet