added db null value handling
working copy, with tests