add cunti library and refactoring db_state