completed functions for prog assignment 3