Fix bug for issue #507