New version of collection script, with changes as indicated by Daniela