Problem 43, need to optimize