logic error - fixed