fix for #980

Would that be a reasonable fix? It seems to work but I have no idea about potential side effects.