added the checking of number of instances