Refactored into a class with nice member functions