Fixed issue #781

As the title says, this fixes issue #781