Moved constructor out of loop