tweaked for octave