fixing premature end