Updating the code to work with classes