almost working, null value issues