Database function updated