reimplemented issue #46