Error in color blending algorithm