db code almost ready