Fully working code