Created grid function for margins