Fix database interaction