typos and refactoring