solution for stage 3