code optimization
Merge pull request #1693 from stan-bg/patch-15

code optimization