simplified python code