add router function & fix Makefile bugs