Trying to reduce code duplication