Fix null reference

addresses #1291 on github