code corrected - using Scalar instead Mat