Refactoring

Use 'when' instead of 'if' if there is no else part.
Rename variable to good name.