improved relative path detection using regex