improved global flow detection