Update 531.py

Fixed up the logging. Much cleaner now