Issue #8 work, added some error handling.
Finished work on issue #8.