Fixed typos and logic