connecting to db properly finally