now a class!
more refactoring!