Created combined loop for length

Created combined loop for length