seeing as these two scenarios are so similar, is there some way to combine or simplify them?