better connecting to database