select by min method optimized