edited error checking