added some turn management code