updated get unit function