That's a good idea. I'm moved it to a function in core/db