better database handling (based on env)