added makefile, and fixed an infinite loop bug