fix JS error when replaying in certain conditions (thanks gbe)