added some clearing of arrays