The code in the if-else block should be extracted to a separate method to avoid code duplication