added loop to zero out memory etc