Making functional helpers work with references instead of values