fix potential null cases which I forgot to add.