Replaced for loops within tick function with forEach