add percent sign to make sure awk is handling it properly
speed improvements, reducing use of for loops