finish all the codes working

To-do: running on mac to get the result.