improve replay and ghost code