fix bug in thread ahead generator