simplify internal if handling; add isNotNull