removed endfunction for compatibility with Matlab