minor refactoring, fixed typos