Changing sample code to use classes for better usability.