fix: should not increment mid variable.