Opetimize codes for better performance