add rescue block when invalid links are found
fix nil bug