Add null or undefined check when dispatching an action