Fix some logic