Fix clearing array even when limit error occurs