Added a no-db version. But this one should be much cleaner.