adding heap allocation on Q3.cpp