Changed clock logic to make it more accurate