Completed problems 5, 6; can be improved upon though.