Added Sanity checks to ensure element is not null when processing