Full Working Code