Sample implementation on questions posted on Stackoverflow.com