enhance router implemantation and add train api