avoid unnecessary calculations to speed up
read some the comments
Merge branch 'jakwings-patch'