null check before entity encoding