refactor with all-same-or-different?