fix discard function