Fix here-doc + refactor