change "if" to "while" to clean dirty data