begin refactoring frame module, enchance for generality and size