fix variable name
fix logic error