fixed spelling and slightly better error checking.