logic error,fixed some