moved replay code to a seperate file