update time algorithm