Code updated to run faster