added function that counts number of times it is called