Use a helper function to reduce repetitive code