added some kind of clear function before the loop