added some code to save final endmembers for later analysis