Abstract common functionality to reduce code size