Updated database algorithm