fixes discard function