if [ $1 -eq 1 ] ;
then old_prev_array[$previouscounter]=`pwd` ;
if [ -z "$2" ] ;
then \cd ;
else \cd "$2" ;
fi
if [ "`pwd`" != "${old_prev_array[$previouscounter]}" ] ;
then previouscounter=$((previouscounter+1)) ;
maxpreviouscounter=$previouscounter ;
old_prev_array[$previouscounter]=`pwd` ;
fi
fi
if [ $1 -eq 2 ] ;
then if [ $# -eq 1  ] ;
then previoussubtract=1;
else previoussubtract=$2;
fi
if [ $previouscounter -ge $previoussubtract  ] ;
then previouscounter=$((previouscounter-previoussubtract)) ;
\cd "${old_prev_array[$previouscounter]}" ;
else previouscounter=0 ;
\cd ${old_prev_array[0]} ;
fi
fi
if [ $1 -eq 3 ] ;
then if [ $# -eq 1  ] ;
then previoussubtract=1;
else previoussubtract=$2;
fi
if [ $((previouscounter+previoussubtract)) -le $maxpreviouscounter  ] ;
then previouscounter=$((previouscounter+previoussubtract)) ;
\cd "${old_prev_array[$previouscounter]}" ;
else previouscounter=$maxpreviouscounter ;
\cd ${old_prev_array[$maxpreviouscounter]} ;
fi
fi

