add DB and fix some function