Fixed what possibly might have been a major logic error