major refactor of html code as well as php logic