solution to todo6