null checking and adding tpl to data