Fixing issue #189 from Simon Sokolov

This should fix issue #189 with another code rather than #390