Fixed colour detection function