Updated database logic.