Fixed error checking.