fix typos
refactor code a little