Split loop for better performance