fixing bug in python script