Fix: reduce code repetition.