Implemented the 2 functions for the 2nd assignment