Finally I found it!

Ahaha

You can replace counter by boolean variable. It can be faster (but I am not sure).