Check if chat != null, maybe this works