I like this function - maybe move it into the general utils?  it seems like it might be useful elsewhere.