Made the script a bit more efficient.