safer way to get path