replace nargin with exist( , var)
add 2-dimensional versions