Refactoring to fix bug with timings