Fix end condition