Refactored and updated template and code.