Maybe you can pull out the `else` branch into a separate method? (As this one is already quite long)