Fixed handling of last token