Refined the usage of all_equal