first three functions for problem 1