Made localhost work

Make code better.