Fixed logic error
Fixed flag usage per Jeff's recommendation