Optimizing media queries