adds error handling for nested paths