Added error checking for some calls
Fixed a typo