refactored modal rendering to fix bugs and provide more robust/stable renders