Changed funciton to deal with all species in each iteration