Fix logical bug