Added an initial error handling, structured template differently