Reset $value in a loop