This loop could be moved outside...