move null guard to where it's useful