Fixed a mistake when traversing the resultset