Removed an extra iteration and shortened the script