Finished Octave implementation