improve locate file function