Why do we need an additional counter here when this function is called from regularly from the ethersex timer (macro)?
The old code used timer(1) which means HZ interval. Your code uses timer(50) and an count (0-9).
Please re-check or explain your code.