Added template for doc but dirty code
Added fixes to work with doc documents as well