Added variation that allows for returning dict values. Added tests and comments.