refactoring and organizing into packages