Refatoring Q2 to class strucutre