fix bug and add router function