Finished functional programming example
More sensible error catching