I can give you a concrete example.
There is a sub-population of women in prisons who self-harm. All too often, if they display self-harming or inappropriate behaviour, they will be placed in confinement.
There are other solutions, such as psychological support. They can be transferred to more therapeutic environments called secure living environments. They can also undergo more dialectical behaviour therapy, which is designed to specifically treat those types of mental illnesses. Those are some solutions that can be implemented.