Fix for ticket #1228 - thanks to Landry Breuil