Fixed bug in firstE and restE