updated database algorithm