refactor and fix typo