platform detection code optimized