Combine loops, add debug