improve addDatabase function