pull out common helper func