created a more generic helper method