Full working code.