refactored makefile, added error handling. works on mac now.