shell-hell fix lag calculation