Fix and finish code for q1