Replaced awk script with python