modified code to be make into a single page application