Improve pythonic coding style