changed and tested for handling of multiple species