fixed a bug with not opening the database