check for nil properly