safeMode to catch null pointer errors