Fixes some logic