Fix function to check for a win