fix bug introduced in ab0e679 (dont take take ref to front and then pop_front)