extract a couple methods to reduce code complexity