added Makefile and refactoring