Added time measuring function