Use gets and modify instead of get and put with as-pattern.

This refactoring improves the readability of code.