Added setDirection functionality