change cycle function to use classes instead