Updated script for speed and accuracy