This is the code I had written reg. my previous post