Fixed bug in DB connection