xuanloc optimized code