optimized for issue #39