fixed issue where a nullpointerexception would occur