added missing error checking