Solved problem 18.
Added error handling.