Refactor code to fix a typo