more precise error check