Fix IDE warnings
Optimized query