that function also works for directory actually if the tail is a dir...