fix few typos and logical errors