replaced cycle method with shorter way using modulo