Refactor logic of selecting default value.