Fixed issue where "length" property is called on null value