optimized code to only instantiate parentfragment when necessary