Reworked for single db instance