fix typos and logical errors