revise it into class, and change the class name and variables name to make it more understandable