Moved code out into HTML