fix bug in finding min EF