Store the value to compute repeatedly

Also, avoid using `else if` block since early return is used; the block
is not necessary.
Merge pull request #3 from tetsuok/dry-and-avoid-use-elseif-blocks

Store the value to compute repeatedly