Created calculateTime method