renamed utility function as per @maerean's comment