Bug fix for ticket 1292

This solves the ticket -> http://eden.sahanafoundation.org/ticket/1292

I have tested it. Fran look at this, test it and merge it. I think this would be the correct way.

vishrut009