multiple thresholds, twin functions
Automatic style corrections courtesy of autopep8