Improve connecting with db