Cherry-pick from branch 2

Cherry-pick from branch 2
Merge pull request #2 from icdeccc/branch-3

Ok very good code