A Monte Carlo study of the XY model