main
Updated the error handling, added default templates and providing values in any case, leading to overall stability improvement
Added schema validation to avoid errors in the code