minor: reduce code redundancy