Avoid NPE

Error prevention. I just got this error, thought I'd quickly fix it. It's not the best of a fix, but it should (sort of) work.