Whether from the prick of a needle or the burn of a marathon run, here are five ways to help your brain block out pain.

“No pain, no gain,” or so the saying goes. But not all pain yields positive gain.

Luckily, as several new studies demonstrate, the human mind has many ways to trick itself out of mental and physical angst.

According to new research, the brain releases its own painkilling chemicals when we’re faced with social rejection.

In the study, researchers at the University of Michigan’s Molecular and Behavioral Neuroscience Institute showed online dating profiles to 18 adults and asked them to select the people they would like to meet.

After placing them in a positron emission tomography (PET) scanner that measures activity in the brain, they told the subjects that none of their prospective dates were mutually interested.

The scanner showed that the subjects’ brains responded to rejection by releasing painkilling opioids in areas of the brain known to battle physical pain. According to the findings, published in Molecular Psychiatry, those with the highest amount of natural painkiller activation also scored the highest on tests of resilience, or the ability to adjust to change.

“The knowledge that there are chemicals in our brains working to help us feel better after being rejected is comforting,” David Hsu, Ph.D., lead author of the study, said.

A study published last year in the journal Current Biology showed that one way to trick pain away is to find something else to think about.

Researchers at University Medical Center Hamburg-Eppendorf in Germany had subjects concentrate on tasks while painful heat was applied to their arms. Using brain scans, researchers found that concentrating on the task at hand—instead of the pain—helped block pain messages from being sent from the spinal cord to the brain. It also triggered the production of painkilling opioids.

Pain can knock you off your game, but not if you train yourself to frame it in a positive light. For example, if you experience pain after an injury, remind yourself that your body is working to repair the damage.

“Don’t get too emotionally involved with the pain or get upset when you feel it,” long distance runner and performance psychologist Jim Taylor told Runner’s World. “Detach yourself and simply use it as information.”

Try These 7 Simple Tips to Ease Chronic Pain

German researchers have discovered that coughing right as a needle enters your skin can help take the sting out of it.

Researcher Taras Usichenko studied the pain responses of 20 men when they were pricked with a needle and concluded that a simple cough was an easy and free way to take the pain out of routine shots.

Mindful meditation—specifically, focusing on your breathing—has been used to calm the mind for centuries. The simple act of clearing your mind has been shown to have anesthetic qualities.

Studies in the journals Clinical Psychology: Science and Practice and The Journal of Pain have shown that mindful meditation can improve pain ratings for everything from acute pain to chronic lower back pain in the elderly.

Pain and Fatigue: Is It Fibromyalgia?