updated functions for the 2nd Prgm-ing assignments by Buva