Darren Duke
Hi if the frame is loose then you would need to re-fix the frame to the house with frame fixing screws and then fill the gap with expanding foam. It's the foam that really fix's the frame to the wall. When applying the foam don't use to much and give it time to dry before you try and clean any excess foam away from the area. Good luck. Darren, Red Security.