refactorized elapsed time