Fixing typo.
Small refactor of borrowed code.