chances works, but still displays error message after program ends