Optimized Version.