Updated code for timing and improved performance.