added baseLength variable to control both loops