bug fix and output refine