Extracting some logic to methods