temp fix for loop detection, need better solution