adding check for nil data