added some real error handling.