Fixed typo, better error handling.