added grayscale conversion before detectioin