complete Capacity algo and add some log
 Complete algo and fix some problem