Changed algorithum for getting times