adds a couple of null checks.