Added functions to problem 3