Wrote function to find winning move