A sample codes for the question in Stack Overflow