working for discrete variables