INF loop in function