Fixed bug with database connection