Rewrote Script from scratch