Breaking from loop after document id was found