Q4 and Q6 Fixes

Fixed Q4 and Q6 to give correct output.