some minor improvements to code

shout-out to PEP