Unpaid interns can help a business be more productive while also providing crucial training to the next generation of workers. But as attorney Daniel Taylor explains on FindLaw’s Free Enterprise, interns can land a company in court.

According to the U.S. Department of Labor, unpaid internships must be “similar to training which would be given in an educational environment.” The best way to achieve this, Taylor says, is to work with a university or high school to make the internship part of an educational program.

Taylor warns that interns cannot be used to displace paid employees. “If an intern’s work receives the same or similar supervision as that of a regular employee, this will likely be considered displacement of a paid employee,” he says.

His advice: Discuss the length of the unpaid internship before the intern starts, and don’t promise that the stint will lead to a paid spot.

The training provided must benefit the intern, Taylor says, so don’t give the worker menial tasks, such as getting coffee.

Finally, Taylor says, be sure to have the intern sign terms of agreement to ensure both parties are clear on the arrangement. He also suggests adding a nondisparagement clause or liability waiver.