some db refactor