modified to not use dict comprehensions (not available in 2.6)