Fix the selection at cost of o(n²), and other minor improvement