fixed a bug in End
temp