tested database merging
added id checking