Signalgenerator works correctly, but only with one iteration