adding optimized version