modify tail -n1 to -1