Solution for q3