refactor and ensure that the host variable is never written