fix bug and improve routing