check error earlier