begin refactoring, everything works