collapse logic