Fix rect detection