Edited the two provided functions in accordance with assignment 2 criteria