Fix bug for db connection