implemented empty infinity loop detection