typo fix and logic error fix