refactored to avoid second loop in explicit queen or rook check