reorganized makefile output directory
refactoring and adding comments
reduced nested one line if else