Working Code (Tweaked)