Fix database bug