Modified selection script to handle multiple populations