functions for PA 2 completed.