updated for better DB support