Solved problem 127 and optimized problem 124