Updated database code