Hi Rafal
This is a common problem for players who come from a tennis background! A video of your shot would be useful to give more detailed feedback.
To break the habit I’m afraid there are no shortcuts. You need time and many repetitions in all sorts of different situations to make this an automatic action. Giving yourself cues to keep your bat in front of your body and keep your elbow stable will help.
It sounds like you’ve identified where you can make a big improvement so this is great news. Now to put in the work to make the habit stick 👍.