fix bugs and create makefile