added before and after route callback for more deterministic behaviour