would be nice to do this in a database transaction