make Makefile more robust and able to handle different documents