finished problem 26, possible to be optimized a little?