adding error checking