Update sat.py

refactored code