The script seems to be working pretty fine now.