Avoid calling .trim() on undefined