update grep command to put head -n 1 in the right place