slightly restructured code, added a random player