Refactor to use variables and outputs