Refactored from html file to include sessions