modified code to allow localhost editing