How to define nested dict function - Modular