Version with database integration but does not work