Simple loop prevention added