same as before but using a basic counter