two functions created for the assignment2