updates main fn of prog 3 & 7 of cs2