fixed equalize_list_length function