error checking fixed