fix bug and get the final result