I’m replacing an older existing ceiling fan in our home hat was built in 1997, located in Corydon, Indiana. We’ve lived here for 4 years. When I removed the existing ceiling fan, I️ noticed there was no outlet box, the wiring is simply staples to the ceiling joist and the fan itself was screwed into the joist. I’ve replaced several ceiling fans but this is the first time I’ve come across an installation done this way without an outlet box. I am concerned this may not be code and may pose a safety concern. The wire can be pulled down 2-3 inches.