fix the bug to clear data structures after each check