Update 2.py

cleanup and optimization