changing the max gid statement as loop driver