merged Hari's implementation that addresses the issue #14