refactoring a bit, preparing for OO realization