fixed possible race conditions in router