Modified opacity loop for a slight performance increase