typos and minor logic fix