simplied code and makefile