Tiny indentation and readability improvements.
Handled the case when input === output.