Extracted loop from calculate method