updated the code according to https://review.openbloomberg.com/D28#comment-1