add two new helper functions, and factor the (general) helpers into util.R