would be nice to abstract this into a named function