better path checking