Reorganize logic to make code more clear
Merge pull request #35 from robertyseward/adjust-len

Reorganize logic to make code more clear.