reorganized code into framework