fix #11 Added some error handling.