improved Q2 solution