Optimized code to not create new fragments if they already exist.