Possible fix for loop when finding an alternative