added both the functions for programming assignment 2