Look for last path element instead of using a fixed one