Changed the code to a class