refactoring and makefile addition