Implemented db handling