added possibility to set vertical and horizontal margins