error checking added