solution for Q3