move out inner loop