fixed bug in python code