bug fixed (end added)