Error checking fixed