Problem 6: re-worked to use entities dictionary.