win condition added and big rewrite