Solution for q4