updated the time efficiency