add some comment and seems right ,except gotoMark, not clear about the fn.