Fix for open the database twice