simplified iterate() and corrected it so memory updates immediately