Fixed a bug in connection to the database