Replaced dict comprehension with a for loop for clarity and to support Python 2.6