make the db connection to be function