added a bit of error handling, just a bit.