Threw a nullpointer, added a check to prevent that.