add solution to Q5.1