add loop removal algorithm