minor change:
add inversion counting
commont out irrelevent codes.