fix rubocop warning 'CyclomaticComplexity'