exit loop once first handler is found