fixed typos, and logic mistakes