improve code in speedrf generator.py