Adjusted codes to integrate with webforms