wrote my functions for assignment 2