problem 12 and 13... 12 could be optimized I think