refine the code and add makefile

refine the code and add makefile