My version of solution with Class and methods