It would be cleaner if this block was within the 'if ('metadata' in currentVideo)' block above. Actually, it would be even cleaner for SubtitleHandler to expose a function to enable subtitles for the video. All functionality related to subtitles would ideally be owned by SubtitleHandler. It could expose a function that is passed the currentVideo object and the player object and all the logic that is here could be moved to the new function. One other thing, the new function would need to test if the currentVideo has metadata, or you could call the new function from within the 'if ('metadata' in currentVideo)' block (not all videos will have metadata).