logic error fixed