minor edits to error check code