Modified script to remove errors