pre-version 1 tested on Matlab2010a