FIxed logic error