changed error state checking