Updated code to get timing as accurate as possible.