error checking and handling works