Fixed possible NPE

switch with possible null fixed