the two functions solving the assignment