Adding correct algorithm for oscillator