Refactored code to use parent.frame, render to string