Implement logging
Use dict comprehension instead of for loop