added some nice error handling