fix access of possibly undefined variable