fixed bugs in last.