Fix issue #540

Sorry, last pull request didn't solve the problem.