Check for null before dereferencing lists