fix bug in safe_nil