added collapse function, tested cronjob