bug fixed with modulo