Script now works as intended.