implements connect to database