finish the least function, ver 1.0