Adding code given from description