Add protection against null ranges