Updated script to possibly handle errors