improve def locating function