script update, now usable as python module