added question 3 solution. cleaned up debug logs