Fixed while. Small logic error.