add db code (unfinished)