added logic to connect to a database