Fixed a nullpointerexception bug.