Added formatTime function