additional check for nil during JSON convertion