converted code into class style