polished python code