Refactored code for iframe player