fix end of timer (issue #1); enhance code readability by autopep8

fix end of timer (issue #1); enhance code readability by autopep8