make code more pythonic

make code more pythonic