Finished first version of solution.