refactor to allow client-side prediction