code refactor and page formatting