Receiving toxic comments from strangers (or even people we know) is a risk most of us take when using social media. With a focus on photo and video sharing, Instagram is one of the worst offenders when it comes to this sort of behavior, but now it’s using AI to tackle the problem.

Late last year, the Facebook-owned company introduced the option to filter out words from users’ comments sections, and even hide entire comments containing words or phrases flagged as inappropriate.

Yesterday, Instagram announced a few improvements to the system, which will now be turned on by default. “Many of you have told us that toxic comments discourage you from enjoying Instagram and expressing yourself freely,” wrote Instagram CEO and co-founder Kevin Systrom. “To help, we’ve developed a filter that will block certain offensive comments on posts and in live video.”

The enhanced filter is powered by machine learning that has been trained using a set of test data. It means the AI should be able to spot offensive comments that it previously failed to identify, and will now take context and relationships into consideration – good news for people who like to use colorful language on their friends’ posts.

Additionally, when a comment is flagged as offensive and gets blocked, it’s blocked for everyone but the person who posted it.

As Wired points out, the system is based on DeepText, an in-house AI tool developed by Facebook. The social media giant has talked about using artificial intelligence to moderate posts on its own platform, especially when it comes to terrorist material, but it seems the exact same system may not be used on both services.

“Facebook and Instagram are different platforms with different user experiences — from the follow model to how comments are used. Although we share the same goal of creating safe communities, we are going to have different approaches. Instagram’s new tools are a great first step that both companies will be able to learn from,” a Facebook spokesperson told Variety.

DeepText is also powering Instagram’s new spam filter, which it has been testing over last few months. The system looks for obvious spam in the comments and will block it from posts and videos.