Refactors code to use localaddress