finished implementation of memdb