rearranged c++ source code and made Makefile