Issue #509 fixed

Fixes Issue #509