add code and explanation