Buildin grid function of margins
building grid function of margins