Refactor calculation time