used mod function inside for loop