move some functions and add comments
updated makefile