Refactor to make code more Pythonic, part 2