Fixed minor error check