wrote some code to make the concept clear