fixed bug with database connection