Fixed typo, also updated exception handling.