applied optimizations to q2 and q3 as well