avoid possible loops
possible bug fix