added file-configurable margins and dir param