Combining both sway and bounce?

Greetings, I was wondering if it was possible to combine both sway and bounce into this script.
Right now, it’s either one or the other, as when you start moving, the sway immediately ends. If there is a way, how would I go about doing this?

	RunService.RenderStepped:Connect(function()
		if FirstPersonMode == true then
			AnimationUpdate()

			Viewmodel:PivotTo(Camera.CFrame * CFrame.new(0,-1.5,0))

			local Rotation = Camera.CFrame:toObjectSpace(PreviousCFrame)
			local X,Y,Z = Rotation:ToOrientation()
			SwayOffset = SwayOffset:Lerp(CFrame.Angles(math.sin(X) * Multiplier, math.sin(Y) * Multiplier, 0), 0.1)

			for i,v in pairs(Gun:GetDescendants()) do
				if v:IsA("BasePart") then
					if isAiming == false then
						v.CFrame = v.CFrame * SwayOffset

					end
				end
			end

			PreviousCFrame = Camera.CFrame
			
			if Humanoid.MoveDirection.Magnitude > 0 then
				local iTime = os.clock()

				local Bounce = math.sin(iTime * Humanoid.WalkSpeed / 3)

				if Bounce >= 0 then
					Bounce = -Bounce

				end

				Viewmodel:PivotTo(Camera.CFrame * CFrame.new(0,-1.5,0):Lerp(CFrame.new(math.cos(Bounce), -1 + Bounce, 0), 0.025))
				
			else
				Viewmodel.HumanoidRootPart.CFrame = Viewmodel.HumanoidRootPart.CFrame:Lerp((Camera.CFrame * CFrame.new(0,-1.5,0)), 0)
				
			end
		end
	end)