updated code by piyush 30-07-2014