fix set_path method, more consistent edge case handling