adding some checking for out of bounds requests for num_instances