refined relative path logic