Refactoring and fix typo

Doesn't look equivalent. What's the reasoning behind the change?