Refactor to set internal vars