added some error handling...