Added getDirection function