Fixing some logic