last version with function definitions and makefile