Gun sways way too much when walking and shooting

Hey guys I’ve looking all over for a solution to my problem but just can’t figure it out. Its driving me nuts. Essentially I have a blend space walk animation that is the character walking while aiming down the iron sights and I’ve created a montage to play when I aim to get rid of the natural sway the walking animation has, however when I start shooting the gun, its starts swaying left to right like a pendulum. I’ve tried blend per bone but that hasn’t helped. I did get rid of the swaying when I switched up the base pose and blend pose by pointing the upper body group to the base pose and the cached animation to the blend pose however when I do this the character’s legs stop functioning. I’ve attached a screenshot below.