Check for NULL before accessing structs