optional field cannot be dynamic
optional field generation added
indent function used instead of hardcoded 4 spaces