fixing message cleanup for loop