How Do I Fix My Tile Edging

Hello,
I am using carpet tile edge trim as a transition from a tile floor to a wood floor and now the nails that hold the trim to the floor is coming loose and the edge trim is ready to come loose also. What is the best way to fasten the edge trim back to the floor?
Thanking you in anticipation

Remove trim, glue a few

Remove trim, glue a few wooden toothpicks in the nail holes. Replace trim using oval head screws slightly longer than the spiral nails that match trim finish.