added completed check algorithm