Optimize codes for better efficiency and better result presentation