Added some more error checking and updated the api doc to correct method name.