Adding the working code.