Added some extremely basic error handling