Solved the problem for the programming assignment