added allow_nil option