Fixed bug when calling generateRoute