fix bugs on Database.php