updated the condense function