completed functions for assignment 2