Optimize the unsafe code